<template>
  <div>
    <div class="login">
      <div class="register">
        <div class="registerform">
          <a-form-model
            ref="form"
            :model="form"
            :rules="rules"
            @submit="handleSubmit"
            @submit.native.prevent
          >
            <a-form-model-item prop="user">
              <a-input
                v-model="form.user"
                placeholder="手机号/邮箱"
                size="large"
              >
                <a-icon slot="prefix" type="user" />
              </a-input>
            </a-form-model-item>
            <div class="code">
              <a-form-model-item prop="verification">
                <a-input
                  v-model="form.verification"
                  placeholder="验证码"
                  size="large"
                >
                  <a-icon slot="prefix" type="phone" />
                </a-input>
              </a-form-model-item>
              <div class="getCode">获取验证码</div>
            </div>
          </a-form-model>
        </div>
        <div class="nextStep" @click="onRegister()">下一步</div>
        <p class="toLogin">已有账号，马上<span @click="Fshow()">登录</span></p>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      form: {
        user: "",
        verification: "",
      },
      rules: {
        user: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        verification: [
          { required: true, message: "请输入验证码", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    handleSubmit(e) {
      console.log(this.form);
    },
    onRegister() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          alert("register");
        } else {
          return false;
        }
      });
    },
    Fshow() {
      this.$emit("Fshow");
    },
  },
};
</script>
<style lang="less" scoped>
.login {
  width: 100%;
  height: calc(100vh - 200px);
  min-height: 450px;
  display: flex;
  align-items: center;
  justify-content: center;
  .register {
    width: 350px;
    .registerform {
      margin-top: 31px;
    }
    .code {
      display: flex;
      .getCode {
        width: 129px;
        height: 40px;
        background-color: #1768e4;
        box-shadow: 0 2px 6px 0 #d8eee1;
        border-radius: 4px;
        color: #fff;
        font-size: 18px;
        line-height: 40px;
        cursor: pointer;
        font-family: Microsoft YaHei;
        font-weight: 400;
        text-align: center;
        margin-left: 20px;
      }
    }
    .agreement {
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #666;
      span {
        color: #1768e4;
        cursor: pointer;
      }
    }
    .nextStep {
      width: 350px;
      height: 40px;
      background-color: #1768e4;
      box-shadow: 0 2px 6px 0 #d8eee1;
      border-radius: 4px;
      color: #fff;
      font-size: 18px;
      line-height: 40px;
      cursor: pointer;
    }
    .toLogin {
      font-size: 14px;
      color: #999;
      span {
        color: #1768e4;
        cursor: pointer;
      }
    }
    .nextStep,
    .toLogin {
      font-family: Microsoft YaHei;
      font-weight: 400;
      text-align: center;
      margin-top: 23px;
    }
  }
}
</style>